﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_login : System.Web.UI.Page
{
    AdminBus adminBus=new AdminBus();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Session["admin_username"] = null;
            Session["admin_permission"] = null;
            Page.SetFocus(txtName);
        }

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
         string username = txtName.Text.Trim();
         string  password = txtPass.Text.Trim();
   

        if (adminBus.IsLogin(username, password))
        {
           

            DataTable table = new DataTable();
            table = adminBus.GetEmployeeByUsernameAndPass(username, password);

            Session["admin_username"] = username;

            Session["admin_permission"] = password;
           // ScriptManager.RegisterStartupScript(this, typeof(Page), "TYCShop.com", "<script>alert('Login successfully')</script>", false);

            Response.Redirect("../users/home.aspx");
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, typeof(Page), "FlowerShop.com", "<script>alert('Login fails ! Username or Password has wrong')</script>", false);
        }
    }
}